// @ FF FrameWork of Javascript 
// @author FangFeng
// @email:fangfeng335@qq.com
// @MSN:fangfeng335@hotmail.com
// @Vision:0.1
// @UpdateTime:2011-1-31
(function() {
    var FF = {
        version: "1.0.0",
        SERVER: "http://localhost:8080/js/"
    };
    window.FF = FF;
})();

(function() {
    var _isReady = false;
    var _importedClasses = new Array();
    var _importedCsses = new Array();

    FF.extendE = function(sub, supper) {
        for (var i in supper) {
            sub[i] = supper[i];
        }
        return sub;
    }
    FF.extendE(FF, {
        isReady: false
    });
    /*------------------*/
    FF.fn = {
        namespace: function() {
            var a = arguments, o = null, d, rt;
            for (var i = 0; i < a.length; i++) {
                d = a[0].split('.');
                rt = d[0];
                eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';');
                for (var j = 1; j < d.length; j++) {
                    o[d[j]] = o[d[j]] || {};
                    o = o[d[j]];
                }
            }
            return o;
        },
        importClass: function(className, b) {
            for (var i = 0; i < _importedClasses.length; i++) {
                if (_importedClasses[i].toLowerCase() == className.toLowerCase()) {
                    return;
                }
            }
            _importedClasses[_importedClasses.length] = className;
            var path = '';
            var paths = className.split(".");
            for (var i = 0; i < paths.length; i++) {
                path += '/' + paths[i];
            }
            var head = document.getElementsByTagName("head")[0];
            if (b && head.hasChildNodes()) {
                var script = document.createElement("script");
                script.setAttribute("type", "text/javascript");
                script.setAttribute("src", FF.SERVER + path + ".js");
                head.insertBefore(script, head.firstChild);
            } else {
                document.write('<script type="text/javascript" src="' + FF.SERVER + path + '.js"></script>');
            }
        },
        importCss: function(cssName, b) {
            for (var i = 0; i < _importedCsses.length; i++) {
                if (_importedCsses[i].toLowerCase() == cssName.toLowerCase()) {
                    return;
                }
            }
            _importedCsses[_importedClasses.length] = cssName;
            var path = '';
            var paths = cssName.split(".");
            for (var i = 0; i < paths.length; i++) {
                path += '/' + paths[i];
            }
            var head = document.getElementsByTagName("head")[0];
            if (b && head.hasChildNodes()) {
                var lk = document.createElement("link");
                lk.setAttribute("rel", "stylesheet");
                lk.setAttribute("type", "text/text");
                lk.setAttribute("href", FF.SERVER + path + ".css");
                head.insertBefore(lk, head.firstChild);
            } else {
                document.write('<link rel="stylesheet" type="text/javascript" href="' + FF.SERVER + path + '.css"></script>');
            }
        },
        xx: function(fn) {
            if (document.addEventListener) {
                document.addEventListener("DOMContentLoaded", function() {
                    document.removeEventListener("DOMContentLoaded", arguments.callee, false);
                    FF.isReady = true;
                    fn();
                }, false);
            } else if (document.attachEvent) {
                if (document.documentElement.doScroll) (function() {
                    if (_isReady) return;
                    try {
                        document.documentElement.doScroll("left");
                    } catch (error) {
                        setTimeout(arguments.callee, 0);
                        return;
                    }
                    FF.isReady = _isReady = true;
                    fn();
                })();
            }
        }, //End onReady
        extend: function(subClass, superClass, overrides) {
            var Temp = function() { }
            Temp.prototype = superClass.prototype;
            subClass.prototype = new Temp();
            subClass.prototype.constructor = subClass;
            if (superClass.prototype.constructor == Object.prototype.constructor) {
                superClass.prototype.constructor = superClass;
            }
            FF.override(subClass, overrides);
            subClass.extend = function(o) { return FF.extend(subClass, o); };
            return subClass;
        },
        override: function(source, overrides) {
            if (!overrides) return;
            var p = source.prototype;
            for (var i in p) {
                p[i] = overrides[i];
            }
            if (FF.Browser.is("ie") && overrides.hasOwnProperty('toString')) {
                p.toString = overrides.toString;
            }
        },
		test:function(t){alert(t)}
    }
    FF.extendE(FF, FF.fn);
})();

